package bid

func Bprice(p float32, r int64, s int64) float32 {
	//底价
	d := float64(p) * float64(1+float64(r)/100)
	if s == 0 {
		return float32(d)
	}
	//溢价
	return float32(d * float64(1+float64(s)/100))
}

// 返点比例：
func PpriceV2(p, pp, pr float32, r, s, f int64) (float32, float32, bool) {
	if pr < pp {
		//小于底价，不成交
		return 0, 0, false
	}
	//只有溢价
	if r == 0 {
		if pr == pp {
			return p, pr, true
		}
		prs := pr
		if f > 0 { //返点比例实时扣除
			prs = pr * (float32(100-f) / 100)
		}
		return float32(float64(prs) / (1 + float64(s)/100)), pr, true
	}
	//有溢价,有底价
	if pr == pp {
		prs := p
		if f > 0 { //返点比例实时扣除
			prs = p * (float32(100-f) / 100)
		}
		return float32(float64(prs) * (1 + float64(r)/100)), pr, true
	}
	prs := pr
	if f > 0 { //返点比例实时扣除
		prs = pr * (float32(100-f) / 100)
	}
	return float32(float64(prs) / (1 + float64(s)/100)), pr, true
}
